package org.example;


import org.example.bean.User;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
@MapperScan("org.example.mapper")
public class MainApplication {
    public static void main(String[] args) {
        // 返回IOC容器
        ConfigurableApplicationContext run =  SpringApplication.run(MainApplication.class, args);

        // 查看容器里的组件
        String[] names = run.getBeanDefinitionNames();
//        for(String name: names) {
//            System.out.println(name);
//        }

        // 从容器中获取组件
        User user01 = run.getBean("user01", User.class);
//        System.out.println(user01);

        // 获取容器中相同类创建的所有组件
        String[] beanNamesForType = run.getBeanNamesForType(User.class);
        for(String bean: beanNamesForType) {
//            System.out.println(bean);
        }



        System.out.println("启动成功");
    }
}